import { Dialog, ListPage, CustomEnum } from 'custom/index'
import { dialog } from '@/utils/dialog'

export default class DialogTable extends ListPage implements Dialog {
  public static name: CustomEnum = 'DialogTable';

  protected get props() {
    return {
      api: this._api
    }
  }

  private _dialogProps: any = {
    modalClass: 'custom-dialog',
    top: '0'
  }
  
  public setDialog(key: string, value: any) {
    this._dialogProps[key] = value
    return this
  }

  public title(title: string) {
    return this.setDialog('title', title)
  }

  public width(width: string | number) {
    return this.setDialog('width', width)
  }

  public open(props: any = {}, dialogProps: any = {}) {
    return dialog(this.getComponent(), Object.assign({}, this._dialogProps, dialogProps), props)
  }
}
